package demo1;

import java.util.Objects;

/**
 * Created with IntelliJ IDEA.
 * Description:简单代码练习
 * User: LianBao
 * Date: 2024-03-08
 * Time: 15:44
 */

class Person {
    private String name;
    private int age;
    public static String classname;


    public static void FuncStatic(String className) {
        Person.classname = className;
        System.out.println(Person.classname);
    }
    public void func() {
        System.out.println("普通方法");
    }


    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    {
        this.age = 10;
        this.name = "LianBao";
    }
    static {
        Person.classname = "Java112";
    }

    @Override
    public String toString() {
        return "Person{" +
                "姓名:'" + name + '\'' +
                "; 年龄:" + age +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Person person = (Person) o;
        return age == person.age && Objects.equals(name, person.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age);
    }
}


public class Test {

    public static void main(String[] args) {
        Person person1 =new Person("ZhangSan",18);
        Person person2 =new Person("ZhangSan",18);
        System.out.println(person1.hashCode());
        System.out.println(person2.hashCode());


    }

    public static void main2(String[] args) {
        String str1 = "ABC";
        String str2 = new String("abc");

        System.out.println(str1);

    }

    public static void main1(String[] args) {
        int a =10;
        Person person1 = new Person("zhangSan",10);

        Person.FuncStatic("C++112");
        person1.func();
        System.out.println(person1);

    }
}
